<?php

namespace V1\Model;

use Think\Exception;
use Think\Model;

class MemberCodeModel extends Model
{
    protected $tableName = 'member_code';

    /**
     * 将邀请信息添加到邀请列表
     * @param  string $apply_code
     * @param string $uid
     * @return bool
     * @throws Exception
     */
    public function addApplyCode($apply_code, $uid)
    {
        $data = ['apply_code' => $apply_code, 'uid' => $uid, 'addtime' => time()];
        $result = $this->data($data)->add();
        if (false === $result) {
            throw new Exception();
        } else {
            if ($result > 0) {
                return true;
            } else {
                return false;
            }
        }
    }
}
